package com.java110.mall.cart.smo.impl;


import com.java110.mall.cart.dao.IHousekeepingServPoolServiceDao;
import com.java110.core.base.smo.BaseServiceSMO;
import com.java110.dto.PageDto;
import com.java110.dto.housekeeping.HousekeepingServPoolDto;
import com.java110.intf.cart.IHousekeepingServPoolInnerServiceSMO;
import com.java110.po.housekeeping.HousekeepingServPoolPo;
import com.java110.utils.util.BeanConvertUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @ClassName FloorInnerServiceSMOImpl
 * @Description 家政维修池内部服务实现类
 * @Author wuxw
 * @Date 2019/4/24 9:20
 * @Version 1.0
 * add by wuxw 2019/4/24
 **/
@RestController
public class HousekeepingServPoolInnerServiceSMOImpl extends BaseServiceSMO implements IHousekeepingServPoolInnerServiceSMO {

    @Autowired
    private IHousekeepingServPoolServiceDao housekeepingServPoolServiceDaoImpl;


    @Override
    public int saveHousekeepingServPool(@RequestBody HousekeepingServPoolPo housekeepingServPoolPo) {
        int saveFlag = 1;
        housekeepingServPoolServiceDaoImpl.saveHousekeepingServPoolInfo(BeanConvertUtil.beanCovertMap(housekeepingServPoolPo));
        return saveFlag;
    }

    @Override
    public int updateHousekeepingServPool(@RequestBody HousekeepingServPoolPo housekeepingServPoolPo) {
        int saveFlag = 1;
        housekeepingServPoolServiceDaoImpl.updateHousekeepingServPoolInfo(BeanConvertUtil.beanCovertMap(housekeepingServPoolPo));
        return saveFlag;
    }

    @Override
    public int deleteHousekeepingServPool(@RequestBody HousekeepingServPoolPo housekeepingServPoolPo) {
        int saveFlag = 1;
        housekeepingServPoolPo.setStatusCd("1");
        housekeepingServPoolServiceDaoImpl.updateHousekeepingServPoolInfo(BeanConvertUtil.beanCovertMap(housekeepingServPoolPo));
        return saveFlag;
    }

    @Override
    public List<HousekeepingServPoolDto> queryHousekeepingServPools(@RequestBody HousekeepingServPoolDto housekeepingServPoolDto) {

        //校验是否传了 分页信息

        int page = housekeepingServPoolDto.getPage();

        if (page != PageDto.DEFAULT_PAGE) {
            housekeepingServPoolDto.setPage((page - 1) * housekeepingServPoolDto.getRow());
        }

        List<HousekeepingServPoolDto> housekeepingServPools = BeanConvertUtil.covertBeanList(housekeepingServPoolServiceDaoImpl.getHousekeepingServPoolInfo(BeanConvertUtil.beanCovertMap(housekeepingServPoolDto)), HousekeepingServPoolDto.class);

        return housekeepingServPools;
    }


    @Override
    public int queryHousekeepingServPoolsCount(@RequestBody HousekeepingServPoolDto housekeepingServPoolDto) {
        return housekeepingServPoolServiceDaoImpl.queryHousekeepingServPoolsCount(BeanConvertUtil.beanCovertMap(housekeepingServPoolDto));
    }

    @Override
    public int queryStaffServCount(@RequestBody HousekeepingServPoolDto housekeepingServPoolDto) {
        return housekeepingServPoolServiceDaoImpl.queryStaffServCount(BeanConvertUtil.beanCovertMap(housekeepingServPoolDto));
    }

    @Override
    public List<HousekeepingServPoolDto> queryStaffServs(@RequestBody HousekeepingServPoolDto housekeepingServPoolDto) {
        //校验是否传了 分页信息

        int page = housekeepingServPoolDto.getPage();

        if (page != PageDto.DEFAULT_PAGE) {
            housekeepingServPoolDto.setPage((page - 1) * housekeepingServPoolDto.getRow());
        }

        List<HousekeepingServPoolDto> housekeepingServPools = BeanConvertUtil.covertBeanList(housekeepingServPoolServiceDaoImpl.queryStaffServs(BeanConvertUtil.beanCovertMap(housekeepingServPoolDto)), HousekeepingServPoolDto.class);

        return housekeepingServPools;
    }

    @Override
    public int queryStaffFinishServCount(@RequestBody HousekeepingServPoolDto housekeepingServPoolDto) {
        return housekeepingServPoolServiceDaoImpl.queryStaffFinishServCount(BeanConvertUtil.beanCovertMap(housekeepingServPoolDto));
    }

    @Override
    public List<HousekeepingServPoolDto> queryStaffFinishServs(@RequestBody HousekeepingServPoolDto housekeepingServPoolDto) {
        //校验是否传了 分页信息

        int page = housekeepingServPoolDto.getPage();

        if (page != PageDto.DEFAULT_PAGE) {
            housekeepingServPoolDto.setPage((page - 1) * housekeepingServPoolDto.getRow());
        }

        List<HousekeepingServPoolDto> housekeepingServPools = BeanConvertUtil.covertBeanList(housekeepingServPoolServiceDaoImpl.queryStaffFinishServs(BeanConvertUtil.beanCovertMap(housekeepingServPoolDto)), HousekeepingServPoolDto.class);

        return housekeepingServPools;
    }

    public IHousekeepingServPoolServiceDao getHousekeepingServPoolServiceDaoImpl() {
        return housekeepingServPoolServiceDaoImpl;
    }

    public void setHousekeepingServPoolServiceDaoImpl(IHousekeepingServPoolServiceDao housekeepingServPoolServiceDaoImpl) {
        this.housekeepingServPoolServiceDaoImpl = housekeepingServPoolServiceDaoImpl;
    }
}
